#!/usr/bin/env bash
# Install git hooks for the facet repository

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
HOOKS_DIR="$REPO_ROOT/.git/hooks"

echo "Installing git hooks..."

# Install pre-push hook
if [ -f "$HOOKS_DIR/pre-push" ]; then
    echo "Warning: pre-push hook already exists, backing up to pre-push.bak"
    mv "$HOOKS_DIR/pre-push" "$HOOKS_DIR/pre-push.bak"
fi

cp "$SCRIPT_DIR/pre-push" "$HOOKS_DIR/pre-push"
chmod +x "$HOOKS_DIR/pre-push"

echo "Installed pre-push hook"
echo "Done! Hooks installed successfully."
